package br.com.saeng2D.util;

//Representacao de uma Coordenada
public class P2D {
	public int x;
	public int y;

	public P2D() {
		this(0, 0);
	}

	public P2D(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public boolean ehIgual(P2D p2d) {
		return x == p2d.x && y == p2d.y;
	}
	
	public int getX() {
		return x;
	}

	public int distancia(P2D p2d) {
		int x = p2d.x - this.x;
		int y = p2d.y - this.y;
		return (int) Math.sqrt(x * x + y * y);
	}
	
	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public String toString() {
		return "P2D[x=" + x + ", y=" + y + "]";
	}
}